package com.wmwsystems.inc.demo.wsclient;

import com.wmwsystems.inc.demo.wsdl.AirCompany;
import com.wmwsystems.inc.demo.wsdl.PullAirCompaniesResponse;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import java.util.List;


public class Application {
    public static void main(String[] args) {

        javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {

                public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {

                    if (hostname.equals("kuda.integration.realobs.com")) {
                        return true;
                    }

                    return false;
                }
            });

        System.setProperty("javax.net.ssl.trustStoreType", "jks");
        System.setProperty("javax.net.ssl.trustStore", "/opt/soft/apache-tomcat-bot/conf/cacerts");
        System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

        //start Spring?
        ApplicationContext ctx = SpringApplication.run(SpringConfiguration.class, args);

        WsClient client = ctx.getBean(WsClient.class);

        long requestVersion = 0;

        PullAirCompaniesResponse response = client.pullAirCompanies(requestVersion);

        final List<AirCompany> airCompanies = response.getAirCompanies().getAirCompany();

        for (AirCompany ac : airCompanies) {
            System.out.println(ac.getName());
        }
    }
}
